package de.piratech.dasding.data.database.couch.adapters;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonDeserialize;

import de.piratech.dasding.data.Event;
import de.piratech.dasding.data.EventCategory;
import de.piratech.dasding.data.Location;
import de.piratech.dasding.data.database.couch.DataType;
import javax.xml.bind.annotation.XmlRootElement;

@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
public class EventAdapter extends Event {

	private String rev;
	private DataType dataType;

	public EventAdapter() {
	}

	public EventAdapter(Event event) {
		setActions(event.getActions());
		setCategory(event.getCategory());
		setContact(event.getContact());
		setDescription(event.getDescription());
		setFinalWorks(event.getFinalWorks());
		setFurtherInformation(event.getFurtherInformation());
		setId(event.getId());
		setLocation(event.getLocation());
		setName(event.getName());
		setPredecessor(event.getPredecessor());
		setProspects(event.getProspects());
		setResponsible(event.getResponsible());
		setStatus(event.getStatus());
		setTime(event.getTime());
	}

	@JsonProperty("_rev")
	public String getRevision() {
		return this.rev;
	}

	public void setRevision(String rev) {
		this.rev = rev;
	}

	@JsonProperty("_id")
	public String getId() {
		return super.getId();
	}

	public DataType getDataType() {
		return dataType;
	}

	public void setDataType(DataType dataType) {
		this.dataType = dataType;
	}

	@Override
	@JsonDeserialize(as = LocationAdapter.class)
	public Location getLocation() {
		return super.getLocation();
	}

	@Override
	@JsonDeserialize(as = EventCategoryAdapter.class)
	public EventCategory getCategory() {
		return super.getCategory();
	}

}
